package com.example.practical_training_projects.controller;
import com.example.practical_training_projects.service.test2Service;
import com.example.practical_training_projects.vo.votest2class;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.practical_training_projects.entity.test2;
import java.util.List;
@RestController
@CrossOrigin //允许跨域执行
@RequestMapping("test2")
public class test2Controller {
    @Autowired
    private test2Service service;

    @GetMapping("/list")
    public List<votest2class> findAlltest2Andclass(Integer ts_uid, String t2_context){
        return service.findtest2BycontextAndclassuid(ts_uid,t2_context);
    }
    //分页
    @GetMapping("/page")
    public PageInfo<votest2class> gettestpage(Integer pageNum, Integer pageSize){
        PageInfo<votest2class> pageInfo = service.findtestpage(pageNum,pageSize);
        return pageInfo;
    }

    @GetMapping("/del/{t2_uid}")
    public  Integer deleteTest2(@PathVariable("t2_uid") Integer t2_uid){
        return service.deleteTest2(t2_uid);
    }

    @PostMapping("add")
    public Integer insertTest2(@RequestBody test2 t2_uid) {
        //@RequestBody能接收转换的字符串，匹配到StudentInfo studentInfo中
        return service.insertTest2(t2_uid);
    }

    @GetMapping("/get/{t2_uid}")
    public test2 findTest2uid(@PathVariable("t2_uid") Integer t2_uid){
        return service.findTest2uid(t2_uid);
    }

    @PostMapping("update")
    public Integer updateTest2(@RequestBody test2 test2){
        return service.updateTest2(test2);
    }

    @GetMapping("/query/{context}")
    public List<test2> getContext2(@PathVariable("context")String t2_context){
        return service.getContest2(t2_context);
    }

//    @GetMapping("/find/{class}")
//    public List<test2> getClass(@PathVariable("class")String t_class){
//        return service.getClass(t_class);
//    }

    @GetMapping("Find/{id}")
    public  List<votest2class> findAlltest2Andclass(@PathVariable("id") Integer t2_uid){
        return service.findAlltest2Andclass();
    }
}
